import { IsOptional, IsEnum, IsString, IsBoolean, IsNumber } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { PaginationDto } from '../../../common/dto/pagination.dto';
import { SecurityEventType, SecurityLevel } from '../entities/security-log.entity';

export class QuerySecurityLogDto extends PaginationDto {
  @ApiPropertyOptional({
    description: '安全事件类型',
    enum: SecurityEventType,
  })
  @IsOptional()
  @IsEnum(SecurityEventType)
  eventType?: SecurityEventType;

  @ApiPropertyOptional({
    description: '安全级别',
    enum: SecurityLevel,
  })
  @IsOptional()
  @IsEnum(SecurityLevel)
  securityLevel?: SecurityLevel;

  @ApiPropertyOptional({
    description: '事件标题关键词',
  })
  @IsOptional()
  @IsString()
  eventTitle?: string;

  @ApiPropertyOptional({
    description: '用户ID',
  })
  @IsOptional()
  @IsString()
  userId?: string;

  @ApiPropertyOptional({
    description: '用户名',
  })
  @IsOptional()
  @IsString()
  username?: string;

  @ApiPropertyOptional({
    description: 'IP地址',
  })
  @IsOptional()
  @IsString()
  ipAddress?: string;

  @ApiPropertyOptional({
    description: '请求URL关键词',
  })
  @IsOptional()
  @IsString()
  requestUrl?: string;

  @ApiPropertyOptional({
    description: '请求方法',
  })
  @IsOptional()
  @IsString()
  requestMethod?: string;

  @ApiPropertyOptional({
    description: '接口名称',
  })
  @IsOptional()
  @IsString()
  apiName?: string;

  @ApiPropertyOptional({
    description: '错误代码',
  })
  @IsOptional()
  @IsString()
  errorCode?: string;

  @ApiPropertyOptional({
    description: 'HTTP状态码',
  })
  @IsOptional()
  @IsString()
  httpStatusCode?: string;

  @ApiPropertyOptional({
    description: '是否已处理',
  })
  @IsOptional()
  @IsBoolean()
  isHandled?: boolean;

  @ApiPropertyOptional({
    description: '处理人ID',
  })
  @IsOptional()
  @IsString()
  handledBy?: string;

  @ApiPropertyOptional({
    description: '开始时间',
    example: 1704067200000,
  })
  @IsOptional()
  @IsNumber()
  startTime?: number;

  @ApiPropertyOptional({
    description: '结束时间',
    example: 1735689599999,
  })
  @IsOptional()
  @IsNumber()
  endTime?: number;
}
